package com.googlecode.monitoria.client.services;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
import com.googlecode.monitoria.client.to.UserTO;

/**
 * Asynchronous {@link MonitoriaService} interface.
 * 
 * @author Ricardo Araújo Santos - ricardo@lsd.ufcg.edu.br
 */
public interface MonitoriaServiceAsync {

	/**
	 * Utility class to get the RPC Async interface from client-side code
	 */
	public static final class Util {
		private static MonitoriaServiceAsync instance;

		public static final MonitoriaServiceAsync getInstance() {
			if (instance == null) {
				instance = (MonitoriaServiceAsync) GWT.create(MonitoriaService.class);
				ServiceDefTarget target = (ServiceDefTarget) instance;
				target.setServiceEntryPoint(GWT.getModuleBaseURL() + "MonitoriaService");
			}
			return instance;
		}

		/**
		 * Private constructor to avoid outside constructor calling.
		 */
		private Util() {
			// Utility class should not be instanciated
		}
	}

	/**
	 * @return
	 */
	void isFirstRun(AsyncCallback<Boolean> callback);
	
	/**
	 * @param password
	 */
	void registerAdmin(String password, AsyncCallback<Void> callback);
	
	/**
	 * Asynchronous version of {@link MonitoriaService#login(String, String)}
	 * @param name
	 * @param password
	 * @param callback
	 */
	void login(String name, String password, AsyncCallback<UserTO> callback);

	/**
	 * @param asyncCallback
	 */
	void getLoggedUser(AsyncCallback<UserTO> asyncCallback);

	/**
	 * @param asyncCallback
	 */
	void logout(AsyncCallback<Void> asyncCallback);
	
	/**
	 * @param teacher
	 * @param asyncCallback
	 */
	void createTeacher(UserTO teacher, AsyncCallback<UserTO> asyncCallback);
}
